package com.limf.consumer.Controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;


@Controller
public class TestConsumerController {

	@Autowired
	private RestTemplate restTemplate;
	
//	@Value("${user.userServicePath}")
//	private String userServicePath;
	
	@RequestMapping("/consumer/{id}")
	public String queryListToProvider(@PathVariable int id, Model mode) {
		List list = this.restTemplate.getForObject("http://microapp/provider/"+id, List.class);
		Map<String, Object> student = new HashMap();
		student.put("name", "张三丰");
		student.put("vlist", list);
		mode.addAttribute("student", student);
		
		return "/html/index";
	}
	
	@RequestMapping("/index1")
	public String hello(Model mode) {
		System.out.println("进来 hello了");
		Map<String, Object> student = new HashMap();
		student.put("name", "张三丰");
		mode.addAttribute("student", student);
		
		return "/html/index";
	}
	
}
